package events

import "github.com/google/uuid"

// UserCreatedEvent 用户创建事件
type UserCreatedEvent struct {
	BaseEvent
	UserID   uuid.UUID `json:"user_id"`
	Username string    `json:"username"`
	Balance  float64   `json:"balance"`
}

func NewUserCreatedEvent(userID uuid.UUID, username string, balance float64) *UserCreatedEvent {
	return &UserCreatedEvent{
		BaseEvent: BaseEvent{},
		UserID:    userID,
		Username:  username,
		Balance:   balance,
	}
}

func (e *UserCreatedEvent) EventName() string {
	return "user.create"
}

// UserPasswordUpdateEvent 用户密码更新事件
type UserPasswordUpdateEvent struct {
	BaseEvent
	UserID uuid.UUID `json:"user_id"`
}

func NewUserPasswordUpdateEvent(userID uuid.UUID) *UserPasswordUpdateEvent {
	return &UserPasswordUpdateEvent{
		BaseEvent: NewBaseEvent(),
		UserID:    userID,
	}
}

func (e *UserPasswordUpdateEvent) EventName() string {
	return "user.password_update"
}

// UserBalanceUpdateEvent 用户余额更新事件
type UserBalanceUpdateEvent struct {
	BaseEvent
	UserID     uuid.UUID `json:"user_id"`
	Amount     float64   `json:"amount"`
	NewBalance float64   `json:"new_balance"`
}

func NewUserBalanceUpdateEvent(userID uuid.UUID, amount float64, newBalance float64) *UserBalanceUpdateEvent {
	return &UserBalanceUpdateEvent{
		BaseEvent:  NewBaseEvent(),
		UserID:     userID,
		Amount:     amount,
		NewBalance: newBalance,
	}
}

func (e *UserBalanceUpdateEvent) EventName() string {
	return "user.balance_update"
}
